package jp.co.hcs.attendancemanagement.data.dao.impl;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

import jp.co.hcs.attendancemanagement.data.dao.WorkingTimeMasterDAO;
import jp.co.hcs.attendancemanagement.data.entity.WorkingTimeMaster;
import jp.co.hcs.attendancemanagement.data.entity.ex.WorkingTimeMasterExample;
import jp.co.hcs.attendancemanagement.data.entity.ex.WorkingTimeMasterParameter;

public class WorkingTimeMasterDAOImpl extends BaseDAOImpl implements WorkingTimeMasterDAO {

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public WorkingTimeMasterDAOImpl() {
        super();
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int countWorkingTimeMasterByExample(WorkingTimeMasterExample example) throws SQLException {
        Integer count = (Integer)  sqlMapClient.queryForObject("tb5_shugyo_master.ibatorgenerated_countByExample", example);
        return count;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int deleteWorkingTimeMasterByExample(WorkingTimeMasterExample example) throws SQLException {
        int rows = sqlMapClient.delete("tb5_shugyo_master.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int deleteWorkingTimeMasterByPrimaryKey(String workingTimeId) throws SQLException {
        WorkingTimeMaster key = new WorkingTimeMaster();
        key.setWorkingTimeId(workingTimeId);
        int rows = sqlMapClient.delete("tb5_shugyo_master.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public void insertWorkingTimeMaster(WorkingTimeMaster record) throws SQLException {
        sqlMapClient.insert("tb5_shugyo_master.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public void insertWorkingTimeMasterSelective(WorkingTimeMaster record) throws SQLException {
        sqlMapClient.insert("tb5_shugyo_master.ibatorgenerated_insertSelective", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    @SuppressWarnings("unchecked")
    public List<WorkingTimeMaster> selectWorkingTimeMasterByExample(WorkingTimeMasterExample example) throws SQLException {
        List<WorkingTimeMaster> list = sqlMapClient.queryForList("tb5_shugyo_master.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public WorkingTimeMaster selectWorkingTimeMasterByPrimaryKey(String workingTimeId) throws SQLException {
        WorkingTimeMaster key = new WorkingTimeMaster();
        key.setWorkingTimeId(workingTimeId);
        WorkingTimeMaster record = (WorkingTimeMaster) sqlMapClient.queryForObject("tb5_shugyo_master.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int updateWorkingTimeMasterByExampleSelective(WorkingTimeMaster record, WorkingTimeMasterExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("tb5_shugyo_master.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int updateWorkingTimeMasterByExample(WorkingTimeMaster record, WorkingTimeMasterExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("tb5_shugyo_master.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int updateWorkingTimeMasterByPrimaryKeySelective(WorkingTimeMaster record) throws SQLException {
        int rows = sqlMapClient.update("tb5_shugyo_master.ibatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int updateWorkingTimeMasterByPrimaryKey(WorkingTimeMaster record) throws SQLException {
        int rows = sqlMapClient.update("tb5_shugyo_master.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }
    
	public List<WorkingTimeMaster> getAllWorkingTimeMaster()
			throws SQLException {
		return selectWorkingTimeMasterByExample(new WorkingTimeMasterExample());
	}
	
	@SuppressWarnings("unchecked")
	public WorkingTimeMaster getAssignWorkingTimeMaster(String employeeId, Date date) throws SQLException {
		WorkingTimeMasterParameter param = new WorkingTimeMasterParameter();
		param.setEmployeeId(employeeId);
		param.setInputDate(date);
		List<WorkingTimeMaster> list = sqlMapClient.queryForList("tb5_shugyo_master.getAssignWorkingTimeMaster", param);
		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}

    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table tb5_shugyo_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    private static class UpdateByExampleParms extends WorkingTimeMasterExample {
        private Object record;

        public UpdateByExampleParms(Object record, WorkingTimeMasterExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }

}